package it.blueocean.acanto.web.platform.components.panel;

import it.blueocean.acanto.web.platform.components.feedback.SelectModalWindow;

import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;

public class AcantoPanel extends Panel
{
	private static final long serialVersionUID = 1843571071937951022L;

	private ModalWindow errorFeedbackModalWindow = new SelectModalWindow("errorModalWindow", "Errore di validazione", 300, 155);

	private ModalWindow successFeedbackModalWindow = new SelectModalWindow("successModalWindow", "Azione eseguita", 300, 155);

	AcantoStandardForm<?> acantoStandardForm;

	public AcantoPanel(String id)
	{
		super(id);
	}
	
	public final class AcantoStandardForm<T> extends StandardFormField<T>
	{
		private static final long serialVersionUID = 1L;

		public AcantoStandardForm(String id, IModel<T> model)
		{
			super(id, model);
			
			add(errorFeedbackModalWindow);
			add(successFeedbackModalWindow);
			
			setOutputMarkupId(true);
		}

		public AcantoStandardForm(String id)
		{
			super(id);
			
			add(errorFeedbackModalWindow);
			add(successFeedbackModalWindow);
			
			setOutputMarkupId(true);
		}
		
	}

	public class StandardFormField<T> extends StatelessForm<T>
	{
		private static final long serialVersionUID = 152935048215475502L;

		public StandardFormField(String id)
		{
			super(id, new CompoundPropertyModel<T>(new Object()));
		}
		
		public StandardFormField(String id, IModel<T> model)
		{
			super(id, model);
		}
	}

	public ModalWindow getErrorFeedbackModalWindow()
	{
		return errorFeedbackModalWindow;
	}

	public void setErrorFeedbackModalWindow(ModalWindow errorFeedbackModalWindow)
	{
		this.errorFeedbackModalWindow = errorFeedbackModalWindow;
	}

	public ModalWindow getSuccessFeedbackModalWindow()
	{
		return successFeedbackModalWindow;
	}

	public void setSuccessFeedbackModalWindow(ModalWindow successFeedbackModalWindow)
	{
		this.successFeedbackModalWindow = successFeedbackModalWindow;
	}

	public AcantoStandardForm<?> getAcantoStandardForm()
	{
		return acantoStandardForm;
	}

	public void setAcantoStandardForm(AcantoStandardForm<?> acantoStandardForm)
	{
		this.acantoStandardForm = acantoStandardForm;
	}

}
